home *** CD-ROM | disk | FTP | other *** search
/ Java Certification Exam Guide / McGrawwHill-JavaCertificationExamGuide.iso / pc / Web Links and Code / rev / chap4 / q1.java < prev    next >
Encoding:
Java Source  |  1997-05-08  |  381 b   |  23 lines

  1. class Acc2 {
  2.    public static void main(String[] args) {
  3.       First s = new Second();
  4.       Second s2 = (Second)s;
  5.       System.out.println(s2.var);
  6.       System.out.println(s2.method());
  7.    }
  8. }
  9.  
  10. class First {
  11.    int var = 1;
  12.    int method() {
  13.       return var;
  14.    }
  15. }
  16.  
  17. class Second extends First {
  18.    int var = 2;
  19.    int method() {
  20.       return var;
  21.    }
  22. }
  23.